package lanQiaoBei.testQuestions.编程题;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class 子串分值 {
    static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    final static int N=100010;
    static char[]str=new char[N];
    static int set[]=new int[26];
    public static void main(String[]args)throws Exception{
        br.read(str);
        if(str[5]=='\n') System.out.println("yes");
        long res=0L;
        for(int i=0;str[i]!='\n';i++){
            int t=0;
            Arrays.fill(set, 0);
            for(int j=i;str[j]!='\n';j++){
                int u=str[j]-'a';
                ++set[u];
                if(set[u]<=1){
                    t++;
                }
                else if(set[u]<=2){
                    t--;
                }
                res+=t;
            }
        }
        System.out.print(res);
    }

}

